package com.fine.spark.connector.mysql.beans

import com.fine.spark.connector.base.beans.output.BaseOutputConfig
import com.fine.spark.connector.mysql.output.MysqlOutputWorker

import scala.beans.BeanProperty

/**
 * @author jayce
 * @date 2021/11/20 11:08 PM
 * @version 1.0
 */
class MysqlOutputConfig extends BaseOutputConfig {
  // 我们在classloader中去查找所有实现了BaseOutputConfig类，然后把type作为标识
  setType("mysql")

  setWorkerClass(classOf[MysqlOutputWorker].getName)

  @BeanProperty
  var driver: String = _

  @BeanProperty
  var url: String = _

  @BeanProperty
  var user: String = _

  @BeanProperty
  var password: String = _

  @BeanProperty
  var srcTable: String = _

  @BeanProperty
  var dstTable: String = _

  @BeanProperty
  var mode: String = "append"

  @BeanProperty
  var options: java.util.Map[String, String] = _

  @BeanProperty
  var preSQL: java.util.List[String] = _

  override def check(): Unit = {
    super.check()
    this.checkNotNull("user", "password", "srcTable", "dstTable", "mode", "workerClass")
  }
}
